package me.ezitku.base.extensions

import android.view.View
import android.view.animation.AnimationUtils
import com.daimajia.androidanimations.library.Techniques
import com.daimajia.androidanimations.library.YoYo
import me.ezitku.base.R


var View.anim: Techniques
    get() = throw Exception("قىممىتىگە ئېرىشىشنىڭ ھاجىتى يوق!!")
    set(value) {
        YoYo.with(value)
                .duration(700)
                .playOn(this)
    }

fun View.animation(anim:Techniques,duration:Long){
    YoYo.with(anim)
            .duration(duration)
            .playOn(this)
}


fun View.errAnim() {
    anim = Techniques.Shake
}


fun View.startAnim(animRes: Int) {
    startAnimation(AnimationUtils.loadAnimation(this.context, animRes))
}

fun View.clearAnim() {
    clearAnimation()
}

/**
 * توختىماي ئايلاندۇرۇش
 */
fun View.rotateIndefinitely() {
    startAnimation(AnimationUtils.loadAnimation(this.context, R.anim.rotate_indefinitely))
}